using CodePlex.DnD4eCampaignManager.CampaignManagerControlLibrary;
using CodePlex.DnD4eCampaignManager.DnD4e;
using CodePlex.DnD4eCampaignManager.DnD4e.Interfaces;
using CodePlex.DnD4eCampaignManager.Presentation.ViewInterfaces;
using CodePlex.DnD4eCampaignManager.Repositories;
using CodePlex.DnD4eCampaignManager.Repositories.XmlRepositories;
using CodePlex.DnD4eCampaignManager.Services;
using CodePlex.DnD4eCampaignManager.Services.Interfaces;
using StructureMap;

namespace CodePlex.DnD4eCampaignManager
{
    public static class ServiceLocator
    {
        public static T GetInstance<T>()
        {
            return ObjectFactory.GetInstance<T>();
        }

        public static void Initialize()
        {
            ObjectFactory.Configure(
                x =>
                    {
                        x.ForRequestedType<IDungeonsAndDragonsInsiderMonsterImporter>().TheDefault.Is.OfConcreteType
                            <DungeonsAndDragonsInsiderMonsterImporter>();
                        x.ForRequestedType<IDungeonsAndDragonsInsiderPlayerCharacterImporter>().TheDefault.Is.OfConcreteType
                            <DungeonsAndDragonsInsiderPlayerCharacterImporter>();
                        x.ForRequestedType<ILocationRepository>().TheDefault.Is.OfConcreteType<LocationXmlRepository>();
                        x.ForRequestedType<IMonsterRepository>().TheDefault.Is.OfConcreteType<MonsterXmlRepository>();
                        x.ForRequestedType<IPlayerCharacterRepository>().TheDefault.Is.OfConcreteType<PlayerCharacterXmlRepository>();
                        x.ForRequestedType<IOpenFileView>().TheDefault.Is.OfConcreteType<CustomOpenFileControl>();
                        x.ForRequestedType<IAbilities>().TheDefault.Is.OfConcreteType<Abilities>();
                        x.ForRequestedType<IDefenses>().TheDefault.Is.OfConcreteType<Defenses>();
                        x.ForRequestedType<IHealingSurges>().TheDefault.Is.OfConcreteType<HealingSurges>();
                        x.ForRequestedType<IHitPoints>().TheDefault.Is.OfConcreteType<HitPoints>();
                        x.ForRequestedType<IMonster>().TheDefault.Is.OfConcreteType<Monster>();
                        x.ForRequestedType<IMovement>().TheDefault.Is.OfConcreteType<Movement>();
                        x.ForRequestedType<IPlayerCharacter>().TheDefault.Is.OfConcreteType<PlayerCharacter>();
                        x.ForRequestedType<IPowers>().TheDefault.Is.OfConcreteType<Powers>();
                        x.ForRequestedType<ISenses>().TheDefault.Is.OfConcreteType<Senses>();
                    }
                );
        }
    }
}